<?php
namespace app\admin\model;

use think\Exception;
use think\facade\Request;
use think\Model;

//首页轮播
class Banner extends Model{
    protected $pk='id';
        //轮播图列表页展示
     public static function   bannerList(){
         $list=Banner::where('if_show','=',1)->select()->toArray();
         return $list;
         }
         //轮播图添加
     public static function   bannerAdd($post){
         try{
             $res=Banner::insert($post);
         }catch (Exception $e){
            $res=false;
         }
         return $res;
         }
     //轮播修改
     public static function   bannerEdit($param){
         if (Request::isPost()){
             try{
                 $res=Banner::update($param);
             }catch (Exception $e){
                 $res=false;
             }
             return $res;
         }else{
             $find=Banner::find($param['id'])->toArray();
             return $find;
         }
         }
     //轮播删除
     public static function   bannerDel($get){
         try{
             $res=Banner::destroy($get['id']);
         }catch (Exception $e){
             $res=false;
         }
          return $res;
         }
}